<template>
  <div class="index-container" @touchstart="handleTouchStart" @touchend="handleTouchEnd">
    <div class="content-wrapper">
      <!-- 商品展示区域 -->
      <div class="product-showcase">
        <el-card class="product-card">
          <div class="product-image">
            <img src='@/img/img1.jpg' alt="饮品图片">
          </div>
          <div class="product-info">
            <h3 class="welcome-title">欢迎来到无爱咖啡</h3>
          </div>
        </el-card>
      </div>
      <!-- 配送方式选择 -->
      <div class="delivery-options">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-card class="delivery-card" @click="selectDeliveryMethod('selfPickup')">
              <div class="delivery-icon">
                <el-icon><TakeawayBox /></el-icon>
              </div>
              <div class="delivery-text">自提</div>
              <div class="sub-text">下单免排队</div>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="delivery-card" @click="selectDeliveryMethod('delivery')">
              <div class="delivery-icon">
                <el-icon><Van /></el-icon>
              </div>
              <div class="delivery-text">外卖</div>
              <div class="sub-text">专业配送</div>
            </el-card>
          </el-col>
        </el-row>
      </div>
      <div class="coupon-entry">
  <el-card class="entry-card" @click="$router.push('/coupon')">
    <div class="entry-icon">
      <el-icon><Discount /></el-icon>
    </div>
    <div class="entry-text">优惠券中心</div>
    <div class="sub-text">领券立减，省更多</div>
  </el-card>
</div>
      <!-- 底部导航栏 -->
      <BottomNav />
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { Discount } from '@element-plus/icons-vue'
import { TakeawayBox, Van } from '@element-plus/icons-vue'
import BottomNav from '@/components/BottomNav.vue'
import { useRouter } from 'vue-router'

const router = useRouter()


const selectDeliveryMethod = (method) => {
  if (method === 'delivery') {
    ElMessage({
      message: '当前还不支持外卖哦',
      type: 'warning',
      duration: 2000
    })
    return
  }
  router.push('/cart')
}
</script>

<style scoped>
.index-container {
  padding: 16px;
  padding-bottom: 60px;
}

.content-wrapper {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

.product-showcase {
  margin-bottom: 20px;
}

.product-card {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease;
}
.product-card:hover {
  transform: translateY(-4px);
}

.product-image img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-bottom: 1px solid #eee;
}


.product-info {
  padding: 12px;
  text-align: center;
}

.welcome-title {
  font-size: 20px;
  color: #333;
  font-weight: bold;
  text-align: center;
  margin-top: 12px;
}

.price {
  color: #ff6b6b;
  font-size: 18px;
  font-weight: bold;
  margin-top: 8px;
}

.delivery-options {
  margin: 24px 0;
}

.delivery-card {
  background-color: #f9f9f9;
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  border: 1px solid transparent;
}
.delivery-card:hover {
  background-color: #f0f5ff;
  border-color: #5c6bc0;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(92, 107, 192, 0.15);
}
.delivery-icon {
  font-size: 36px;
  color: #5c6bc0;
  margin-bottom: 10px;
}
.delivery-text {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 6px;
}

.sub-text {
  font-size: 12px;
  color: #888;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  padding: 8px 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
  text-decoration: none;
  color: inherit;
}

.nav-item:hover {
  color: #ff6b6b;
}

.nav-item.active {
  color: #ff6b6b;
}
@media (max-width: 768px) {
  .content-wrapper {
    width: 95%;
    padding: 12px;
  }

  .product-image img {
    height: 180px;
  }

  .delivery-card {
    padding: 16px;
  }

  .delivery-text {
    font-size: 15px;
  }
}
.delivery-card:hover .delivery-icon {
  color: #5c6bc0;
}

.delivery-card:hover .delivery-text {
  color: #5c6bc0;
}
.coupon-entry {
  margin: 24px 0;
}

.entry-card {
  background-color: #f9f9f9;
  border-radius: 16px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  border: 1px solid transparent;
}
.entry-card:hover {
  background-color: #f0f5ff;
  border-color: #5c6bc0;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(92, 107, 192, 0.15);
}
.entry-icon {
  font-size: 32px;
  color: #5c6bc0; /* 和配送方式图标一致 */
  margin-bottom: 8px;
}
.entry-text {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 4px;
}
.sub-text {
  font-size: 12px;
  color: #888;
}
</style>